package com;

import com.MybatisUtil.MybatisUtil;
import com.bean.News;
import com.dao.NewsMapper;
import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Demo {
    @Test
    public void findAllWithReplys(){
        NewsMapper dao = MybatisUtil.getMapper(NewsMapper.class);
        News news = dao.findNewsWithReplys(1);
        Assert.assertNotNull(news);
    }

    @Test
    public void find(){
        Map<String,Object> params = new HashMap<>();
        NewsMapper dao = MybatisUtil.getMapper(NewsMapper.class);
        List<News> list = dao.find(params);
        Assert.assertNotNull(list);
        Assert.assertEquals(1,list.size());
        params.put("category_id","1");
        list = dao.find(params);
        Assert.assertNotNull(list);
        Assert.assertEquals(1,list.size());
        params.clear();
        params.put("1","1");
        list = dao.find(params);
        Assert.assertNotNull(list);
        Assert.assertEquals(1,list.size());
        MybatisUtil.close();
    }
}
